package Controller;


import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Enumeration;
import java.util.Hashtable;

public class MyUltilities {
    public static String replace(Hashtable<String, String> dic, String content)
    {
        if (dic != null)
        {
            for(int i=0; i< dic.size(); i++)
            {
                for(Enumeration e = dic.keys(); e.hasMoreElements();)
                {
                    String key = (String)e.nextElement();
                    content = content.replace("{"+ key +"}", dic.get(key));
                }
            }
        }
        
        return content;
    }
    public static String readFile(String path, Charset encoding)
            throws IOException {
        byte[] encoded = Files.readAllBytes(Paths.get(path));
        return encoding.decode(ByteBuffer.wrap(encoded)).toString();
    }
}
